package com.lp.company.service;

import com.lp.common.utils.IdWorker;
import com.lp.company.dao.CompanyDao;
import com.lp.domain.company.Company;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lipengak
 * @Description
 * @Date 2020/1/31 1:10
 * @Copyright 2019-2020
 */
@Service
public class CompanyService {

    @Autowired
    private CompanyDao companyDao;

    @Autowired
    private IdWorker idWorker;

    /**
     * 保存企业
     */
    public void add(Company company) {
        company.setId(idWorker.nextId() + "");
        company.setAuditState("0");
        company.setState(1);
        companyDao.save(company);
    }

    /**
     * 更新企业
     */
    public void update(Company company) {
        Company temp = companyDao.findById(company.getId()).get();

    }

    /**
     * 根据企业ID查询
     */
    public Company findById(String id) {
        return companyDao.findById(id).get();
    }

    /**
     * 分页查询列表
     */
    public List<Company> findAll() {
        return companyDao.findAll();
    }


    /**
     * 删除企业
     */
    public void deleteById(String id) {
        companyDao.deleteById(id);
    }
}
